import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

import static java.util.stream.Collectors.groupingBy;

/**
 * @author honway.liu
 * @date 2017/9/22 下午9:50
 * @email gm100861@gmail.com
 * @blog http://linuxsogood.org
 */
public class GroupSum {

    public static void main(String[] args) {

        System.out.println(6&1);
        System.out.println(3&1);

        List<CommodityVo> commodityVos = Arrays.asList(
                new CommodityVo(12345L, 5),
                new CommodityVo(45678L, 9),
                new CommodityVo(12345L, 3),
                new CommodityVo(56789L, 2),
                new CommodityVo(12305L, 5));
        Map<Long, Integer> collect = commodityVos.parallelStream().collect(groupingBy(CommodityVo::getId, Collectors.summingInt(CommodityVo::getQuantity)));
        collect.forEach((k,v) -> System.out.println("key:" + k + ",value:" + v));


    }

}
